import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:provider/provider.dart';
import 'package:znmm/UI/A_Common/custom_web_view.dart';
import 'package:znmm/UI/Kline_Demo/FloatingScrollbarList2.dart';
import 'package:znmm/UI/Kline_Demo/MarketProvider.dart';
import 'package:znmm/UI/Kline_Demo/MarketScreen.dart';
// import 'package:glassesin/UI/A_Common/buttons/easy_button/easy_elevated_button.dart';
// import 'package:glassesin/UI/A_Common/custom_search_field.dart';
// import 'package:glassesin/UI/A_Common/image/openImg_view.dart';
import 'package:znmm/config/app_asset.dart';
import 'package:znmm/config/app_color.dart';
import 'package:znmm/config/app_gaps.dart';

import '../../Kline_Demo/FloatingScrollbarList.dart';
import '../../Kline_Demo/kline_demo.dart';
import '../../Kline_Demo/stock_page.dart';
import 'search_page.dart';
import '../../Kline_Demo/stock_table_page.dart';

class HomeAppBar extends StatefulWidget implements PreferredSizeWidget {
  const HomeAppBar({super.key});

  @override
  // ignore: library_private_types_in_public_api
  _HomeAppBarState createState() => _HomeAppBarState();

  @override
  Size get preferredSize => const Size.fromHeight(kToolbarHeight); //90 +
}

class _HomeAppBarState extends State<HomeAppBar>
    with SingleTickerProviderStateMixin {
  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return AppBar(
      backgroundColor: AppColor.white,
      flexibleSpace: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        mainAxisAlignment: MainAxisAlignment.center,
        children: [
          // const SizedBox(
          //   height: kToolbarHeight,
          // ),
          Expanded(
              child: Row(
            children: [
              AppGaps.hGaps15w,
              GestureDetector(
                onTap: () {
                  Get.to(const CustomWebView(
                    titleStr: "",
                    initialUrl: "https://www.glassesin.com/",
                  ));
                },
                child: Image.asset(
                  AppAsset.imageLogo,
                  width: 55,
                  //color: AppColor.white,
                ),
              ),
              AppGaps.hGaps10w,

              // Search bar
              // Expanded(
              //   child: SizedBox(
              //     height: 40,
              //     child: CustomSearchField(
              //       hintText: '搜索公司名/人名/职位(英文)',
              //       onTextChanged: (value) {
              //         //print('User entered: $value');
              //       },
              //     ),
              //   ),
              // ),
              // const SizedBox(width: 8),
              // EasyElevatedButton(
              //   isRounded: true,
              //   label: '搜索',
              //   color: AppColor.lightBlack,
              //   onPressed: () {
              //     Navigator.push(
              //       context,
              //       MaterialPageRoute(
              //           builder: (context) => const OpenImgView()),
              //     );
              //   },
              // ),

              const Text(
                "Glassesin",
                style: TextStyle(
                  fontSize: 16,
                  fontWeight: FontWeight.bold,
                ),
              ),
              const Spacer(),
              IconButton(
                icon: const Icon(Icons.search, color: Colors.black),
                onPressed: () {
                  //Get.to(const SearchPage());
                  // Get.to(const CustomWebView(
                  //   titleStr: "",
                  //   initialUrl: "https://www.glassesin.com/",
                  // ));
                  //Get.to(const MarketScreen());

                  // Get.to(
                  //   ChangeNotifierProvider(
                  //     create: (_) => MarketProvider(),
                  //     child: const MarketScreen(),
                  //   ),
                  // );

                  //Get.to(const StockPage());
                  //Get.to(const FloatingScrollbarList());
                  Get.to(const FloatingScrollbarList2());
                },
              ),
              AppGaps.hGaps5w,
            ],
          )),
          AppGaps.vGaps5w,
        ],
      ),
    );
  }
}
